// 页面加载完成后执行
    window.addEventListener('load', function() {
      // 隐藏加载动画
      setTimeout(() => {
        const loader = document.querySelector('.loader');
        loader.style.opacity = '0';
        setTimeout(() => {
          loader.style.display = 'none';
        }, 800);
      }, 1500);
      
      // 初始化轮播
      initCarousel();
      
      // 初始化滚动监听
      initScrollEffects();
      
      // 初始化导航菜单
      initNavigation();
      
      // 初始化元素动画
      initElementAnimations();
    });
    
    // 视频加载完成
    function videoLoaded() {
      const videoLoading = document.querySelector('.video-loading');
      videoLoading.style.opacity = '0';
      setTimeout(() => {
        videoLoading.style.display = 'none';
      }, 1000);
    }
    
    // 轮播图功能实现
    function initCarousel() {
      const carouselImages = document.querySelectorAll('.carousel-img');
      const prevBtn = document.querySelector('.carousel-btn.prev');
      const nextBtn = document.querySelector('.carousel-btn.next');
      const indicators = document.querySelectorAll('.indicator');
      let currentIndex = 0;
      let carouselInterval;
      
      // 开始轮播
      function startCarousel() {
        carouselInterval = setInterval(nextSlide, 5000);
      }
      
      // 显示指定索引的幻灯片
      function showSlide(index) {
        // 隐藏所有图片
        carouselImages.forEach(img => img.classList.remove('active'));
        // 移除所有指示器的活跃状态
        indicators.forEach(ind => ind.classList.remove('active'));
        
        // 确保索引在有效范围内
        if (index < 0) {
          currentIndex = carouselImages.length - 1;
        } else if (index >= carouselImages.length) {
          currentIndex = 0;
        } else {
          currentIndex = index;
        }
        
        // 显示当前图片和激活当前指示器
        carouselImages[currentIndex].classList.add('active');
        indicators[currentIndex].classList.add('active');
      }
      
      // 下一张幻灯片
      function nextSlide() {
        showSlide(currentIndex + 1);
      }
      
      // 上一张幻灯片
      function prevSlide() {
        showSlide(currentIndex - 1);
      }
      
      // 事件监听
      prevBtn.addEventListener('click', function() {
        clearInterval(carouselInterval);
        prevSlide();
        startCarousel();
      });
      
      nextBtn.addEventListener('click', function() {
        clearInterval(carouselInterval);
        nextSlide();
        startCarousel();
      });
      
      // 指示器点击事件
      indicators.forEach((indicator, index) => {
        indicator.addEventListener('click', function() {
          clearInterval(carouselInterval);
          showSlide(index);
          startCarousel();
        });
      });
      
      // 鼠标悬停暂停轮播
      const carousel = document.querySelector('.carousel');
      carousel.addEventListener('mouseenter', () => {
        clearInterval(carouselInterval);
      });
      
      carousel.addEventListener('mouseleave', () => {
        startCarousel();
      });
      
      // 开始自动轮播
      startCarousel();
    }
    
    // 初始化滚动效果
    function initScrollEffects() {
      const scrollDownBtn = document.getElementById('scrollDown');
      const bottomText = document.getElementById('bottomText');
      const topText = document.getElementById('topText');
      const container = document.querySelector('.container');
      
      // 向下滚动按钮点击事件
      scrollDownBtn.addEventListener('click', () => {
        container.scrollIntoView({ behavior: 'smooth' });
      });
      
      // 滚动监听
      window.addEventListener('scroll', () => {
        const scrollPosition = window.scrollY;
        
        // 显示/隐藏底部文字和滚动提示
        if (scrollPosition > 50) {
          bottomText.classList.add('hidden');
          scrollDownBtn.classList.add('hidden');
          container.classList.add('visible');
        } else {
          bottomText.classList.remove('hidden');
          scrollDownBtn.classList.remove('hidden');
        }
        
        // 显示/隐藏顶部文字
        if (scrollPosition > 300) {
          topText.classList.remove('scrolled');
        } else {
          topText.classList.add('scrolled');
        }
        
        // 检查元素是否在视口中
        checkElementsInView();
      });
      
      // 初始触发一次滚动事件以设置正确状态
      setTimeout(() => {
        window.dispatchEvent(new Event('scroll'));
      }, 100);
    }
    
    // 初始化导航菜单
    function initNavigation() {
      const menuItems = document.querySelectorAll('.menu-item');
      const mobileMenuBtn = document.getElementById('mobileMenuBtn');
      const sideNav = document.getElementById('sideNav');
      
      // 菜单点击事件
      menuItems.forEach(item => {
        item.addEventListener('click', () => {
          // 移除所有活跃状态
          menuItems.forEach(i => i.classList.remove('active'));
          // 添加当前活跃状态
          item.classList.add('active');
          
          // 在移动设备上点击后关闭菜单
          if (window.innerWidth <= 768) {
            sideNav.classList.remove('open');
            mobileMenuBtn.innerHTML = '<i class="fas fa-bars"></i>';
          }
          
          // 获取目标区域并滚动
          const targetId = item.getAttribute('data-target');
          const targetElement = document.querySelector(`[data-section="${targetId}"]`);
          if (targetElement) {
            targetElement.scrollIntoView({ behavior: 'smooth' });
          }
        });
      });
      
      // 移动端菜单按钮点击事件
      mobileMenuBtn.addEventListener('click', () => {
        sideNav.classList.toggle('open');
        if (sideNav.classList.contains('open')) {
          mobileMenuBtn.innerHTML = '<i class="fas fa-times"></i>';
        } else {
          mobileMenuBtn.innerHTML = '<i class="fas fa-bars"></i>';
        }
      });
    }
    
    // 初始化元素动画
    function initElementAnimations() {
      // 触发一次检查
      checkElementsInView();
    }
    
    // 检查元素是否在视口中
    function checkElementsInView() {
      const descParagraphs = document.querySelectorAll('.desc p');
      
      descParagraphs.forEach((paragraph, index) => {
        const rect = paragraph.getBoundingClientRect();
        const isInView = (
          rect.top >= 0 &&
          rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
        );
        
        if (isInView) {
          setTimeout(() => {
            paragraph.style.opacity = '1';
            paragraph.style.transform = 'translateY(0)';
          }, index * 100);
        }
      });
    }
    
    // 了解更多按钮点击事件
    document.querySelector('.know-more-btu').addEventListener('click', () => {
      alert('更多共创计划内容即将上线，敬请期待！');
    });